package com.demo.controller;

import java.util.HashMap;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.TimeUnit;

import com.demo.sdk.CCPRestSDK;
import com.demo.sdk.CCPRestSDK.BodyType;
import com.demo.sdk.CCPRestSDK;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;

public class SDKTestSendTemplateSMS {
	@Autowired
	public static StringRedisTemplate stringRedisTemplate;
	/**
//	 * @param args
	 */
//	public static void main(String[] args) {
		public void show(String phone,String str){
		HashMap<String, Object> result = null;
		HomeController homeController=new HomeController();
		CCPRestSDK restAPI = new CCPRestSDK();
		restAPI.init("app.cloopen.com", "8883");// 初始化服务器地址和端口，格式如下，服务器地址不需要写https://
		restAPI.setAccount("8aaf07086f6955dd016f7891ee770684", "8177f5bf3204494481041b9a0b1d6a2c");// 初始化主帐号和主帐号TOKEN
		restAPI.setAppId("8aaf07086f6955dd016f7891eed2068a");// 初始化应用ID
        result = restAPI.sendTemplateSMS(phone,"1" ,new String[]{str,"1"});
		System.out.println("SDKTestSendTemplateSMS result=" + result);

		if("000000".equals(result.get("statusCode"))){
			//正常返回输出data包体信息（map）
			HashMap<String,Object> data = (HashMap<String, Object>) result.get("data");
			Set<String> keySet = data.keySet();
			for(String key:keySet){
				Object object = data.get(key);
				System.out.println(key +" = "+object);
			}
		}else{
			//异常返回输出错误码和错误信息
			System.out.println("错误码=" + result.get("statusCode") +" 错误信息= "+result.get("statusMsg"));
		}
	}
}
//}
